package com.j2eefast.flowable.bpm.service;


import cn.hutool.core.util.IdUtil;
import com.j2eefast.flowable.bpm.entity.bpmCrmTransportEntity;
import com.j2eefast.flowable.bpm.mapper.bpmCrmTransportMapper;
import com.j2eefast.common.core.mutidatasource.annotaion.DataSource;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.common.core.utils.ToolUtil;
import com.j2eefast.framework.utils.Constant;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.Arrays;
/**
 *
 * 运输Service接口
 * @author: yhli
 * @date 2020-06-28 22:17
 */
@Service
public class bpmCrmTransportService extends ServiceImpl<bpmCrmTransportMapper,bpmCrmTransportEntity> {

	@Resource
	private bpmCrmTransportMapper bpmCrmTransportMapper;

	/**
	 * mybaitis-plus 页面分页查询
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params) {
        QueryWrapper<bpmCrmTransportEntity> queryWrapper = new QueryWrapper<bpmCrmTransportEntity>();
              String saleCode = (String) params.get("saleCode");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleCode), "sale_code", saleCode);
                               String saleUserid = (String) params.get("saleUserid");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleUserid), "sale_userid", saleUserid);
          String saleOrderNumber = (String) params.get("saleOrderNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleOrderNumber), "sale_order_number", saleOrderNumber);
          String outCarVin = (String) params.get("outCarVin");
         queryWrapper.eq(ToolUtil.isNotEmpty(outCarVin), "out_car_vin", outCarVin);
          String outCarVehicle = (String) params.get("outCarVehicle");
         queryWrapper.eq(ToolUtil.isNotEmpty(outCarVehicle), "out_car_vehicle", outCarVehicle);
          String transportTakeCarPlace = (String) params.get("transportTakeCarPlace");
         queryWrapper.eq(ToolUtil.isNotEmpty(transportTakeCarPlace), "transport_take_car_place", transportTakeCarPlace);
          String transportSelectColleague = (String) params.get("transportSelectColleague");
         queryWrapper.eq(ToolUtil.isNotEmpty(transportSelectColleague), "transport_select_colleague", transportSelectColleague);
          String transportTakeCarAddress = (String) params.get("transportTakeCarAddress");
         queryWrapper.eq(ToolUtil.isNotEmpty(transportTakeCarAddress), "transport_take_car_address", transportTakeCarAddress);
          String transportTakeCarPhone = (String) params.get("transportTakeCarPhone");
         queryWrapper.eq(ToolUtil.isNotEmpty(transportTakeCarPhone), "transport_take_car_phone", transportTakeCarPhone);
          String transportGiveCarPlace = (String) params.get("transportGiveCarPlace");
         queryWrapper.eq(ToolUtil.isNotEmpty(transportGiveCarPlace), "transport_give_car_place", transportGiveCarPlace);
          String transportGiveSelectColleague = (String) params.get("transportGiveSelectColleague");
         queryWrapper.eq(ToolUtil.isNotEmpty(transportGiveSelectColleague), "transport_give_select_colleague", transportGiveSelectColleague);
          String transportGiveCarAddress = (String) params.get("transportGiveCarAddress");
         queryWrapper.eq(ToolUtil.isNotEmpty(transportGiveCarAddress), "transport_give_car_address", transportGiveCarAddress);
          String transportGiveCarPhone = (String) params.get("transportGiveCarPhone");
         queryWrapper.eq(ToolUtil.isNotEmpty(transportGiveCarPhone), "transport_give_car_phone", transportGiveCarPhone);
          String approvalCurrentStatus = (String) params.get("approvalCurrentStatus");
         queryWrapper.eq(ToolUtil.isNotEmpty(approvalCurrentStatus), "approval_current_status", approvalCurrentStatus);
             String approvalPlanTakeCarTime = (String) params.get("approvalPlanTakeCarTime");
         queryWrapper.eq(ToolUtil.isNotEmpty(approvalPlanTakeCarTime), "approval_plan_take_car_time", approvalPlanTakeCarTime);
          String approvalPlanArriveTime = (String) params.get("approvalPlanArriveTime");
         queryWrapper.eq(ToolUtil.isNotEmpty(approvalPlanArriveTime), "approval_plan_arrive_time", approvalPlanArriveTime);
          String approvalOrderid = (String) params.get("approvalOrderid");
         queryWrapper.eq(ToolUtil.isNotEmpty(approvalOrderid), "approval_orderid", approvalOrderid);
          String approvalCentralDispatchFee = (String) params.get("approvalCentralDispatchFee");
         queryWrapper.eq(ToolUtil.isNotEmpty(approvalCentralDispatchFee), "approval_central_dispatch_fee", approvalCentralDispatchFee);
          String transportCompanyName = (String) params.get("transportCompanyName");
        queryWrapper.like(ToolUtil.isNotEmpty(transportCompanyName), "transport_company_name", transportCompanyName);
          String transportCompanyCheckAddress = (String) params.get("transportCompanyCheckAddress");
         queryWrapper.eq(ToolUtil.isNotEmpty(transportCompanyCheckAddress), "transport_company_check_address", transportCompanyCheckAddress);
          String transportMail = (String) params.get("transportMail");
         queryWrapper.eq(ToolUtil.isNotEmpty(transportMail), "transport_mail", transportMail);
             String cashierPayTime = (String) params.get("cashierPayTime");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierPayTime), "cashier_pay_time", cashierPayTime);
          String cashierPayMethod = (String) params.get("cashierPayMethod");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierPayMethod), "cashier_pay_method", cashierPayMethod);
          String cashierPayProofFilepath = (String) params.get("cashierPayProofFilepath");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierPayProofFilepath), "cashier_pay_proof_filepath", cashierPayProofFilepath);
          String cashierReceiptNumber = (String) params.get("cashierReceiptNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierReceiptNumber), "cashier_receipt_number", cashierReceiptNumber);
             String confirmPayMethod = (String) params.get("confirmPayMethod");
         queryWrapper.eq(ToolUtil.isNotEmpty(confirmPayMethod), "confirm_pay_method", confirmPayMethod);
          String confirmPayAmount = (String) params.get("confirmPayAmount");
         queryWrapper.eq(ToolUtil.isNotEmpty(confirmPayAmount), "confirm_pay_amount", confirmPayAmount);
             String confirmPaySum = (String) params.get("confirmPaySum");
         queryWrapper.eq(ToolUtil.isNotEmpty(confirmPaySum), "confirm_pay_sum", confirmPaySum);
             String transportTotalCost = (String) params.get("transportTotalCost");
         queryWrapper.eq(ToolUtil.isNotEmpty(transportTotalCost), "transport_total_cost", transportTotalCost);
  		Page<bpmCrmTransportEntity> page = bpmCrmTransportMapper.selectPage(new Query<bpmCrmTransportEntity>(params).getPage(), queryWrapper);
		return new PageUtil(page);
    }

    /**
     * 自定义分页查询，含关联实体对像
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params,bpmCrmTransportEntity bpmCrmTransportEntity) {
		Page<bpmCrmTransportEntity> page = bpmCrmTransportMapper.findPage(new Query<bpmCrmTransportEntity>(params).getPage(), bpmCrmTransportEntity,(String) params.get(Constant.SQL_FILTER))  ;
		return new PageUtil(page);
	}
	/**
     * 批量删除
     */
    @DataSource(name="FLOWABLE")
	@Transactional(rollbackFor = Exception.class)
	public boolean deletebpmCrmTransportByIds(String[] ids) {
		return removeByIds(Arrays.asList(ids));
	}

	/**
     * 单个删除
     */
    @DataSource(name="FLOWABLE")
	public boolean deletebpmCrmTransportById(String id) {
		return removeById(id);
	}

	/**
     * 保存
     */
    @DataSource(name="FLOWABLE")
	public boolean savebpmCrmTransport(bpmCrmTransportEntity bpmCrmTransport){
        bpmCrmTransport.setId(IdUtil.fastSimpleUUID());
        return save(bpmCrmTransport);
    }

	/**
     * 修改根居ID
     */
    @DataSource(name="FLOWABLE")
	public boolean updatebpmCrmTransportById(bpmCrmTransportEntity bpmCrmTransport) {
		return updateById(bpmCrmTransport);
	}

	/**
     * 根居ID获取对象
     */
    @DataSource(name="FLOWABLE")
	public bpmCrmTransportEntity getbpmCrmTransportById(String id){
		return getById(id);
	}
}
